<template>
	<div class="all">
		<el-container>
		 <!-- 侧边栏-查询患者信息start -->
		  <el-aside width="25%">
			 <div class="selectRegister" >
			  					  <el-form ref="Register"  :model="user" label-width="80px">
			  				        <el-form-item label="姓名:">
			  				           <el-input v-model="user.RealName" placeholder="请输入查询的姓名"></el-input>
			  				        </el-form-item>
			  				        <el-form-item label="病历号:">
			  				            <el-input v-model="user.CaseNumber" placeholder="请输入查询的病历号"></el-input>
			  				        </el-form-item>
			  				      </el-form>
			  					  <div align="center">
			  						  <el-button @click="selectRegister()">查询</el-button>
			  					  </div>
			  					  
			  				  </div>
			  				  <div style="border-bottom: 1px solid #000000;">
			  					  <p>未填写患者信息</p>
			  				  </div>
			  				  <div style="margin: 5px;">
			  						<el-table
			  						    :data="register"
			  						    border>
			  						    <el-table-column
			  						      fixed
			  						      prop="caseNumber"
			  						      label="病历号"
			  						      width="75%">
			  						    </el-table-column>
			  						    <el-table-column
			  						      prop="realName"
			  						      label="姓名"
			  						      width="75%">
			  						    </el-table-column>
			  						    <el-table-column
			  						      prop="age"
			  						      label="年龄"
			  						      width="75%">
			  						    </el-table-column>
			  						    <el-table-column
			  						      fixed="right"
			  						      label="操作"
			  							  width="60%">
			  						      <template slot-scope="scope">
			  						        <el-button @click="handleClick(scope.row.id,scope.row.realName,scope.row.caseNumber,scope.row.idnumber)" type="text" size="small" icon="el-icon-edit"></el-button>
			  						      </template>
			  						    </el-table-column>
			  						  </el-table>
			  				 </div>

		</el-aside>
		<!-- 侧边栏-查询患者信息end -->
		<!-- 主模块-填写患者病历首页信息start -->
		  <el-main>
			<div class="mainAll" >
				<div class="top">
					&nbsp;<span>门诊病历信息</span>&nbsp;&nbsp;
					<span>{{username}}</span>
					<div class="wordsubmit">
					<el-link type="primary" @click="clearScreen()">清屏</el-link>&nbsp;&nbsp;&nbsp;
					<el-link type="primary" @click="temporaryStorage()">暂存</el-link>&nbsp;&nbsp;&nbsp;
					<el-link type="primary" @click="homeSubit()">提交</el-link>&nbsp;&nbsp;&nbsp;
					</div>
				</div>
					<div v-show="hasPatientHome">
						<el-form :rules="patientrules" ref="patientHome" :model="patientHome" label-width="80px">
						  <el-form-item label="主诉：">
						    <el-input placeholder="请填写主诉" v-model="patientHome.Readme"></el-input>
						  </el-form-item>
						  <el-form-item  label="现病史：">
						    <el-input placeholder="请填写现病史" v-model="patientHome.Present"></el-input>
						  </el-form-item>
						  <el-form-item  label="现病治疗情况：">
						    <el-input placeholder="请填写现病治疗情况" v-model="patientHome.PresentTreat"></el-input>
						  </el-form-item>
						  <el-form-item label="既往史：">
						    <el-input placeholder="请填写既往史" v-model="patientHome.History"></el-input>
						  </el-form-item>
						  <el-form-item label="过敏史：">
						    <el-input placeholder="请填写过敏史" v-model="patientHome.Allergy"></el-input>
						  </el-form-item>
						  <el-form-item label="体格检查：">
						    <el-input placeholder="请填写体格检查" v-model="patientHome.Physique"></el-input>
						  </el-form-item>
						   <hr/>
						   <div>
							   <span>西医诊断</span>
							   <el-form-item label="疾病名称：">
							     <el-input placeholder="请填写疾病名称" v-model="patientHome.DiseaseNamex"></el-input>
							   </el-form-item>
							   <el-form-item label="发病日期：">
							     	<el-input placeholder="请填写发病日期" v-model="patientHome.GetSiskDatex"></el-input>
							   </el-form-item>
						   </div>
						   <hr/>
						   <div>
						   	<span>中医诊断</span>
						   	<el-form-item label="疾病名称：">
						   	<el-input placeholder="请填写疾病名称" v-model="patientHome.DiseaseNamez"></el-input>
						   	</el-form-item>
						   	<el-form-item label="发病日期：">
						   	<el-input placeholder="请填写发病日期" v-model="patientHome.GetSiskDatez"></el-input>
						</el-form-item>
						   </div>
						</el-form>
					</div>
					
				
			</div>
		  </el-main>
		 <!-- 主模块-填写患者病历首页信息end -->
		  <!-- 侧边栏-查询患者信息start -->
		 <!-- <el-aside class="rightaside" width="25%">
			  <div class="top" style="padding-left:40%;">
					<el-link type="primary" @click="inquireHistoryMessage()">查看历史病历信息</el-link> 
				</div>
					 <hr>
					 <div>看诊时间：{{patienthistory.medicaldisease.getSiskDate}}</div>
					 <div>主诉:{{patienthistory.medicalrecord.readme}}</div>
					 <div>现病史：{{patienthistory.medicalrecord.present}}</div>
					 <div>体格检查：{{patienthistory.medicalrecord.Physique}}</div>
					 <div>检查结果：{{patienthistory.medicalrecord.checkResult}}</div>
					 <div>诊断结果：{{patienthistory.medicalrecord.diagnosis}}</div>
					 <div>检查建议：{{patienthistory.medicalrecord.proposal}}</div>
					 <div>注意事项：{{patienthistory.medicalrecord.careful}}</div>
			  
		  </el-aside> -->
		  
		  <!-- 侧边栏-查询患者信息end-->
		</el-container>
	</div>
</template>

<script>
	export default{
		name:"OutpatientHomePage",
		data(){	
	    return {
		  user:{
			RealName:"",
			CaseNumber:"",
		  },
	      register:[],
		  username:"",
		  specialuser:{
			RealName:"",
			CaseNumber:"",
			idnumber:"",
		  },
		  patientHome:{
			  CaseNumber:"",
			  RegistID:"",
			  Readme:"",
			  Present:"",
			  PresentTreat:"",
			  History:"",
			  Allergy:"",
			  Physique:"",
			  GetSiskDate:"",
			  DiseaseName:"",
			  GetSiskDatex:"",
			  DiseaseNamex:"",
			  GetSiskDatez:"",
			  DiseaseNamez:"",
			  DiagnoseType:"",
			  CaseState:"",
			  DiagnoseCate:"",
		  },
		  patient:{
		  			  CaseNumber:"",
		  			  RegistID:"",
		  },
		  patientall:{
			medicalrecord:{
			readme:"",
			present:"",
			presentTreat:"",
			history:"",
			allergy:"",
			physique:"",
		  },
		  medicaldisease:{
			diseaseName:"",
			getSiskDate:"", 
			diagnoseType:"",
		  },
		  register:{
			  visitDate:"",
		  },
		  state:"",
		  diseaseName:"",
		  },
		  patienthistory:{
		  			medicalrecord:{
		  			readme:"",
		  			present:"",
		  			presentTreat:"",
		  			history:"",
		  			allergy:"",
		  			physique:"",
					checkResult:"",
					diagnosis:"",
					proposal:"",
					careful:""
		  },
		  medicaldisease:{
		  			diseaseName:"",
		  			getSiskDate:"", 
		  			diagnoseType:"",
		  },
		  register:{
		  			  visitDate:"",
		  },
		  state:"",
		  diseaseName:"",
		  },
		   hasPatientHome:false,
		  patientrules:{
			Readme:[{required: true, message: '请输入主诉', trigger: 'blur'}],
			Present:[{required: true, message: '请输入主诉', trigger: 'blur'}],
			PresentTreat:[{required: true, message: '请输入主诉', trigger: 'blur'}],
			History:[{required: true, message: '请输入主诉', trigger: 'blur'}],
			Allergy:[{required: true, message: '请输入主诉', trigger: 'blur'}],
			Physique:[{required: true, message: '请输入主诉', trigger: 'blur'}],
		  }
	    }
	  },
	 mounted(){
	 	this.selectRegister();
	 },
	  methods:{
		  //查询患者病历信息
			selectRegister(){
				// let url='/UserController';
				let url='/outpatientHomepage/selectNoCheckedRegister';
				let param=this.$qs.stringify(this.user);
				this.$axios.post(url,param)
				.then((resp)=>{
					this.register =resp.data;
				})
				.catch((err)=>{
					console.log('error=',err);
				})
			},
			//得到患者的某些信息
			handleClick(id,realname,caseNumber,idnumber){
				 this.username = realname;
				 this.patient.CaseNumber=caseNumber;
				 this.patient.RegistID=id;
				 this.hasPatientHome = true;
				 this.specialuser.CaseNumber = caseNumber;
				 this.specialuser.RealName = realname;
				 this.specialuser.idnumber = idnumber;
				 console.log(this.patientHome);
				 this.getPatientMessage();
			},
			//暂存患者的首页信息
			temporaryStorage(){
				console.log("-------"+this.patientHome.DiseaseNamex);
				console.log("___-----"+this.patientHome.DiseaseNamez);
				if(this.patientHome.DiseaseNamex==""&&this.patientHome.DiseaseNamez==""){
					console.log();
					this.$message({
						          message: '疾病信息不能为空',
						          type: 'warning'
						        });
					return;
				}else if(this.patientHome.GetSiskDatex==""&&this.patientHome.GetSiskDatez==""){
					console.log();
					this.$message({
						          message: '发病日期不能为空',
						          type: 'warning'
						        });
					return;
				}else{
					if(this.patientHome.DiseaseNamex!=""){
						this.patientHome.DiseaseName = this.patientHome.DiseaseNamex;
						this.patientHome.GetSiskDate = this.patientHome.GetSiskDatex;
						this.patientHome.DiagnoseType="1";
						this.patientHome.CaseState = "1";
						this.patientHome.DiagnoseCate="1";
						console.log("==========="+this.patientHome.GetSiskDate);
						this.submitRequest();
						this.selectRegister();
					}else if(this.patientHome.DiseaseNamez!=""){
						this.patientHome.DiseaseName = this.patientHome.DiseaseNamez;
						this.patientHome.GetSiskDate = this.patientHome.GetSiskDatez;
						this.patientHome.DiagnoseType="2";
						this.patientHome.CaseState = "1";
						this.patientHome.DiagnoseCate="1";
						this.submitRequest();
						this.selectRegister();
					}else{
						this.$message({
							          message: '填写错误',
							          type: 'warning'
							        });
					}
					
				}
			},
			//提交数据给后端
			submitRequest(){
				let url='/outpatientHomepage/temporaryHomeInfromation';
				this.patientHome.CaseNumber = this.patient.CaseNumber;
				this.patientHome.RegistID = this.patient.RegistID;
				console.log(this.patientHome.CaseNumber);
				let param=this.$qs.stringify(this.patientHome);
				this.$axios.post(url,param)
					.then((resp)=>{
						this.$message(resp.data);
					})
					.catch((err)=>{
						console.log('error=',err);
					})
			},
			//提交患者首页信息
			homeSubit(){
				console.log("提交");
				if(this.patientHome.DiseaseNamex==""&&this.patientHome.DiseaseNamez==""){
					console.log();
					this.$message({
						          message: '疾病信息不能为空',
						          type: 'warning'
						        });
					return;
				}else if(this.patientHome.GetSiskDatex==""&&this.patientHome.GetSiskDatez==""){
					console.log();
					this.$message({
						          message: '发病日期不能为空',
						          type: 'warning'
						        });
					return;
				}else{
					if(this.patientHome.DiseaseNamex!=""){
						this.patientHome.DiseaseName = this.patientHome.DiseaseNamex;
						this.patientHome.GetSiskDate = this.patientHome.GetSiskDatex;
						this.patientHome.DiagnoseType="1";
						this.patientHome.CaseState = "2";
						
						console.log("==========="+this.patientHome.GetSiskDate);
						this.submitRequest();
						this.selectRegister();
		                console.log("经过这儿了");
					}else if(this.patientHome.DiseaseNamez!=""){
						this.patientHome.DiseaseName = this.patientHome.DiseaseNamez;
						this.patientHome.GetSiskDate = this.patientHome.GetSiskDatez;
						this.patientHome.DiagnoseType="2";
						this.patientHome.CaseState = "2";
						this.submitRequest();
						this.selectRegister();
						console.log("经过这儿了");
					}else{
						this.$message({
							          message: '填写错误',
							          type: 'warning'
							        });
					}
					
				}
			},
			clearScreen(){
				this.patientHome={};
			},
			//获取患者的历史看病信息
			//获得患者病历首页信息
			getPatientMessage(){
				console.log("11111111111111111111111");
				let url='/outpatientHomepage/inquireHistoryMessage';
				let param=this.$qs.stringify(this.specialuser);
				this.$axios.post(url,param)
					.then((resp)=>{
						this.patientall= resp.data;
						if(this.patientall.state==null){
							this.patientHome={};
							console.log("999999999999");
						}else{
							if(this.patientall.state=="暂存"||this.patientall.state=="已提交")
						{
							console.log("8888888888888888888888888888");
							this.patientHome.Readme=this.patientall.medicalrecord.readme;
							console.log(this.patientHome.Readme);
							this.patientHome.Present=this.patientall.medicalrecord.present;
							this.patientHome.PresentTreat=this.patientall.medicalrecord.presentTreat;
							this.patientHome.History=this.patientall.medicalrecord.history;
							this.patientHome.Allergy=this.patientall.medicalrecord.allergy;
							this.patientHome.Physique=this.patientall.medicalrecord.physique;
							if(this.patientall.medicaldisease.diagnoseType==1){
								this.patientHome.DiseaseNamex=this.patientall.diseaseName;
								console.log(this.patientHome.medicaldisease.getSiskDate);
								this.patientHome.GetSiskDatex=this.patientHome.medicaldisease.getSiskDate;
							}else{
								this.patientHome.DiseaseNamey=this.patientall.diseaseName;
								this.patientHome.GetSiskDatey=this.patientHome.medicaldisease.getSiskDate;
							}
					}
						}
						
					})
					.catch((err)=>{
						console.log('error=',err);
					})
					
			},
		}
}
	
</script>

<style>
	html, body, #app, .el-container .el-main{
	    /*统一设置高度为100%*/
	    height: 100%;
		padding: 0px;
	}
	.el-aside {
		height: 100%;
	  }
	  .el-main {
		height: 100%;
		border-right: #000000 1px solid;
		border-top: #000000 1px solid;
		border-left: #000000 1px solid;
		}
	 .selectRegister{
	 	padding: 10px 15px;
	 	border-bottom: 1px solid black;
	 }
     .top{
		background-color: #D7D7D7;
		height: 25px;
		line-height: 25px;
	 }
	 .wordsubmit{
		 display: inline;
		 padding-left: 50%;
		 text-decoration:none;
	 }
	 .mainAll .el-form-item__label{
		font-size: 5px !important;
	 }
	 
</style>
